<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>add_dept.jsp</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" type="text/css" href="./css/style.css">
	<script type="text/javascript">
   	var xmlHttp = null;
	function init() {
		if(window.ActiveXObject){
  			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  		}else{
  			xmlHttp = new XMLHttpRequest();
  		}
	}
	function check1num() {
		if (xmlHttp == null) {
			init();
		}
		 var msg=document.getElementById("msgna");
		var did=document.getElementById("dept1num");
		 if(did.value==""||did.value==null){
        msg.innerHTML="部门编号不能为空";
        }
        else{
		var url = "./dept/checkAction.action?dept1num="+did.value ;
		xmlHttp.open("post", url, true);
		xmlHttp.onreadystatechange = feedbackCallback;
		xmlHttp.send(null);
	}
	}
	function feedbackCallback() {
        var msg=document.getElementById("msgna");
		if (xmlHttp.readyState == 4) {
			var b = xmlHttp.responseText;		
			if (b == "true") {
				msg.innerHTML="";
			} 
		    if(b=="false"){
				msg.innerHTML="部门已存在";
			}
	}
  } 
</script>
    <script type="text/javascript">
   
    function check1name(){
        var name=document.getElementById("dept1name");
        var msg=document.getElementById("msgna");
        if(name.value==""){
        msg.innerHTML="部门名称不能为空";
        }
        }
        function check1phone(){
        var phone=document.getElementById("dept1phone");
        var msg=document.getElementById("msgma");
        if(phone.value.length==0){
        msg.innerHTML="请输入联系电话";
        }
        if(phone.value.matches("\\d{4}-\\d{8}")){
        alert("oo");
        msg.innerHTML="电话格式不对";
        }
        }
    
    </script>
  </head>
  
  <body>
    <div id="blue_button"><div id="blue_button_word">部门管理</div></div>
    
  <div id="right_background">
  &nbsp;
  <br/> <br/> 
  
  <form action="./dept/addDeptAction" method="post" >
  <div id="new_dept">
  &nbsp;&nbsp;<font color="orange">${msg4}</font><br/>
   &nbsp; 部门编号  ：<input type="text"  id="dept1num" name="dept1num" onblur="check1num();"/><font color="red" id="msgnu"></font> 
  &nbsp;部门名称   :  <input type="text" id="dept1name" name="cdept.dname" onblur="check1name();"/><font color="red" id="msgna"></font>    <br/> <br/><br/> 
 &nbsp; 联系电话    :     <input type="text" name="cdept.DPhone" id="dept1phone" onblur="check1phone()" /> 
  &nbsp;部门经理   :   <select name="manager"  style="width: 150px; font-color:darkblue;">
                     <s:iterator value="elist" var="elist">
                     <option value="<s:property value="#elist.EName"/>"><s:property value="#elist.EName"/></option>
                     </s:iterator> 
                     </select>   
                     <font color="red" id="msgma"></font>
                     <br/> <br/> <br/>       
 &nbsp; 部门传真 :   <input type="text" name="cdept.DFax"  />    
   &nbsp;部门状态   :       <select style="width: 150px; font-color:darkblue;" name="cdept.DStatus">
                     <option value="Y" >未删除 </option>
                     <option value="N">已删除</option>
                     </select>
                  <br/> <br/> <br/>
  &nbsp;部门描述   :   <textarea name="cdept.DDescribe" cols="48" rows="5"></textarea> <br/> <br/> <br/>  
  
   <font color="red"  >*部门编号请用数字</font>
  </div>
  <br/>
 
   <br/> 
  <input type="submit" class="del" value="提交" style="margin-top: -100px;
    margin-left: 300px;"/> &nbsp; &nbsp;&nbsp; &nbsp;
  <input type="button" class="add" value="重置" onClick="location.reload()"/>
  </form>
  </div> 
  </body>
</html>
